package com.hr.牛客网剑指offer;

import java.util.Arrays;

/**
 * @author zhz
 * @date 2020/08/22
 **/
public class JZ6_旋转数组的最小数字 {
    //调用api
    public int minNumberInRotateArray(int [] array) {
        Arrays.sort(array);
        return array[0];
    }
    //遍历
    public int minNumberInRotateArray2(int [] array) {
        if(array.length==0){
            return 0;
        }
        int res=0;
        for (int i = 0; i < array.length-1; i++) {
            if (array[i]>array[i+1]){
                res=array[i+1];
            }
        }
        return res;
    }
    //二分
    public int minNumberInRotateArray3(int [] array) {
        if(array.length==0){
            return 0;
        }
        int res=0;
        for (int i = 0; i < array.length-1; i++) {
            if (array[i]>array[i+1]){
                res=array[i+1];
            }
        }
        return res;
    }
}
